package com.ym.b2b.order.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.order.dao.SalesDetailDao;
import com.ym.b2b.order.sqlbean.EmSSaleDetail;
import com.zc.commons.base.Page;

@Repository
public class SalesDetailDaoImpl<T> extends BaseDao<T> implements SalesDetailDao {

    @Override
    public Page<EmSSaleDetail> searchPageSalesDetail(com.ym.b2b.order.sqlbean.EmSSaleDetail emSSaleDetail,
                                                     Page<com.ym.b2b.order.sqlbean.EmSSaleDetail> page)
                                                                                                       throws DataAccessException {
        page.setTotalRow(searchSalesDetailNum(emSSaleDetail));
        Map<String, Object> hmap = new HashMap<String, Object>();
        hmap.put("map", emSSaleDetail);
        hmap.put("startrow", page.getStartRow());
        hmap.put("pagesize", page.getPageSize());
        hmap.put("pageable", page.getPageable());
        page.setRows(list("SalesDetail.searchPageSalesDetail", hmap));
        return page;
    }

    @Override
    public Long searchSalesDetailNum(EmSSaleDetail emSSaleDetail) throws DataAccessException {

        Map<String, Object> hmap = new HashMap<String, Object>();
        hmap.put("map", emSSaleDetail);
        return (Long) listNum("SalesDetail.searchSalesDetailNum", hmap);
    }

}
